home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
yerk
/
mps231ss.hqx
/
Mops source
/
Toolbox classes
/
Window+
< prev
next >
Wrap
Text File
|
1993-02-08
|
3KB
|
140 lines
\ Window+ class - a window that supports views.
\ Oct 91 mrh Initial version.
\ May 92 mrh "New-style" controls
\ Feb 93 mrh Added sending idle: to the contView
need view
need scroller
:class WINDOW+ super{ window }
ptr ^CONTVIEW \ Points to view consisting of contents rect.
bool ZOOMFLG
:m SETZOOM: \ ( b -- ) Passed-in boolean indicates if this window
\ will be zoomable.
put: zoomFlg ;m
:m SETVIEW: { ^view -- }
^view put: ^contView ^base setWindow: ^view ;m
:m GETVIEW: get: ^contView ;m
:m NEW: { bndsRect tAddr tLen procID vis goAway ^view \ s255 -- }
get: alive ?EXIT \ Out if already alive
^view setView: self
?disable_actW: self
tAddr tLen str255 -> s255
0 ^base bndsrect s255 vis Tbool
get: zoomFlg 8 and procID + makeint
inFront goAway Tbool 0
call NewWindow drop
initNewWindow: self
getRect: self init: [ get: ^contView ]
nilP new: [ get: ^contView ] \ Fire up view object
;m
:m GETNEW: { resID ^view -- }
get: alive ?EXIT \ Out if already alive
^view setView: self
resID getnew: super
getRect: self init: [ get: ^contView ]
nilP new: [ get: ^contView ] \ Fire up view object
;m
:m GROW:
grow: super
getRect: self get: ^contView setRect: ** ;m
:m ZOOM:
zoom: super set: super
getRect: self get: ^contView setRect: ** ;m
:m ENABLE:
enable: super \ Note - we do this first to make sure the
\ current grafPort is set before the views
\ do anything.
get: ^contView enable: ** enable: super ;m
:m DISABLE: get: ^contView disable: ** disable: super ;m
:m (DRAW): \ Draws the window with controls
(draw): super
draw: [ get: ^contview ]
^base call DrawControls ;m
:m DRAW: (draw): self ;m
:m IDLE: idle: super
get: ^contView idle: ** ;m
:m CLOSE: \ Disposes of window's controls and closes the window
get: ^contView release: **
^base call KillControls close: super ;m
:m CONTENT: \ Handles a content click
active: self
IF ^base ctlHit?
NIF get: ^contView click: ** drop THEN
ELSE select: self
THEN ;m
:m KEY: \ ( c -- ) For typed keys, we'll send a KEY: to the
\ contView and thus to all the views. They can do
\ whatever they like with it.
get: ^contView key: ** ;m
:m TEST: { ^view -- }
100 100 400 300 put: tempRect
screenbits true setGrow: self
true setZoom: self
tempRect " Test" docWind true true ^view new: self ;m
;class
\ endload
\ TESTING:
window+ WW
scroller S1 20 >toffs: s1
scroller S2 floating floating 2dup setModes: s2
20 20 400 200 init: s2
view VV anchored floating 2dup setModes: vv
32 32 628 328 init: vv
screenbits true setGrow: ww
true setZoom: ww
: DRW { \ l t r b -- } \ Draws a big X across the view area.
clear: temprect get: tempRect -> b -> r -> t -> l
0 0 gotoxy r b pack call LineTo
l b gotoxy r 0 pack call LineTo ;
' drw setDraw: vv
: CLICK1 ." clicked s1!" cr ;
: CLICK2 ." clicked s2!" cr ;
' click1 setClick: s1 ' click2 setClick: s2
: GO
vv addView: s2 s2 addView: s1
s1 test: ww ;
\ : RR \ Test getting things from a resource file
\ " WindTest.rsrc" openresfile
\ 128 db getNew: ww
\ 128 ww getNew: vv1 ;
: ZZ set: fwind close: ww ;